package cn.ekuma.epos.datalogic.define.dao.pda;

import cn.ekuma.data.dao.BaseDAO;
import cn.ekuma.epos.db.table.pda.I_LocalHistory;
import cn.ekuma.epos.db.table.pda.Table;

import com.openbravo.bean.pda.LocalHistory;
import com.openbravo.data.basic.BasicException;
import com.openbravo.data.loader.DataRead;
import com.openbravo.data.loader.DataWrite;
import com.openbravo.data.loader.Datas;
import com.openbravo.data.loader.I_Session;
import com.openbravo.data.loader.TableDefinition;
import com.openbravo.data.model.Field;
import com.openbravo.format.Formats;

public class LocalHistoryDAO extends BaseDAO<LocalHistory>{

	public LocalHistoryDAO(I_Session s) {
		super(s);
	}

	@Override
	public TableDefinition getTable() {
		return new TableDefinition(s,
                Table.LOCAL_HISTORY,
                new Field[]{
                     new Field(I_LocalHistory.ID,Datas.STRING,Formats.STRING),
                     new Field(I_LocalHistory.CREATEDATE,Datas.TIMESTAMP,Formats.TIMESTAMP),
                     new Field(I_LocalHistory.LOCAL_MACHINE_NAME,Datas.STRING,Formats.STRING),
                     new Field(I_LocalHistory.CSV_VALUE,Datas.STRING,Formats.STRING),
                     new Field(I_LocalHistory.MEMO,Datas.STRING,Formats.STRING),
                     new Field(I_LocalHistory.CSV_MORE,Datas.STRING,Formats.STRING)   
                    },
                new int[]{0});
	}

	@Override
	public void writeInsertValues(DataWrite dp, LocalHistory obj)
			throws BasicException {
		dp.setString(1,obj.getId());
		dp.setTimestamp(2,obj.getCreateDate());
		dp.setString(3,obj.getLocalMachineName());
		dp.setString(4,obj.getCsvValue());
		dp.setString(5,obj.getMemo());
		dp.setString(6,obj.getCsvMore());
	}

	@Override
	public Class getSuportClass() {
		return LocalHistory.class;
	}

	@Override
	public LocalHistory readValues(DataRead dr, LocalHistory obj)
			throws BasicException {
		if(obj==null)
			obj=new LocalHistory();
		obj.setId(dr.getString(1));
		obj.setCreateDate(dr.getTimestamp(2));
		obj.setLocalMachineName(dr.getString(3));
		obj.setCsvValue(dr.getString(4));
		obj.setMemo(dr.getString(5));
		obj.setCsvMore(dr.getString(6));
		return obj;
	}

}
